package inits

import (
	"fmt"
	"hxzhz/global/srv"
	orders "hxzhz/kitex_gen/hertz/order/paymentservice"
	payments "hxzhz/kitex_gen/hertz/payment/paymentservice"

	"github.com/cloudwego/kitex/client"
)

func Init() {
	OrderConn()
	PaymentConn()
}

func PaymentConn() {
	newClient, err := payments.NewClient("order", client.WithHostPorts("127.0.0.1:50051"))
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	srv.PaymentSrv = newClient
	fmt.Println("srv conn success")
}

func OrderConn() {
	newClient, err := orders.NewClient("order", client.WithHostPorts("127.0.0.1:50052"))
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	srv.OrderSrv = newClient
	fmt.Println("srv conn success")
}
